package ModelLayer;
/**
 * Objects of class CompositionLine unites a Product object with a quantity.
 * A CompositionLine object is used to add Product objects to a Composition object.
 * 
 * @author  Mie P., Jakob K., Anna K., Anders A.P., Danny M.P.  
 * @version 1.0
 */
public class CompositionLine {

    private int     quantity;
    private Product p;
    private double  linePrice;

    /**
     * Constructor for objects of class CompositionLine.
     * 
     * @param product   the Product object.
     * @param quantity  the quantity of the Product.
     */
    public CompositionLine(Product p, int quantity) {

        setProduct(p);
        setQuantity(quantity);
        calculateLinePrice(p, quantity);

    }

    /**
     * Set the product.
     *
     * @param   p   a Product object.
     */
    private void setProduct(Product p) {

        this.p = p;

    }

    /**
     * Set the quantity.
     *
     * @param   input   quantity of the product.
     */
    public void setQuantity(int input) {

            this.quantity = input;

    }

    /**
     * Calculate the total purchase price of the line.
     *
     * @param   p           a Product object.
     * @param   quantity    quantity of the products.
     */
    private void calculateLinePrice(Product p, int quantity) {

        linePrice = p.getPurchasePrice() * (double)quantity;

    }

    /**
     * Accessor method for product.
     * 
     * @return p    the Product object.
     */
    public Product getProduct() {

        return this.p;

    }
    
    /**
     * Accessor method for quantity.
     * 
     * @return  quantity    the value of quantity.
     */
    public int getQuantity() {

        return this.quantity;

    }
    
    /**
     * Accessor method for linePrice.
     * 
     * @return  linePrice   the value of linePrice, e.g. the total purchase price of the line.
     */
    public double getLinePrice() {

        return this.linePrice;

    }

}